package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.JiJianCaiJiBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_jiehao_caiji.view.*

/**
 * Created by Administrator on 2018/3/30/030.
 * 作者：刘洋
 */
class JiJianCaiJiAdapter(private var JiJianCaiJiBeans : MutableList<JiJianCaiJiBean>, val context : Context) :BaseAdapter() {
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.lv_jiehao_caiji,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        val jiJianCanJiBean= JiJianCaiJiBeans[position]
        Myutil.settv(jiJianCanJiBean.mcode,h.mcodeTv)
        Myutil.settv(jiJianCanJiBean.mb_batch,h.mb_batch)
        Myutil.settv(jiJianCanJiBean.creator_name,h.nameTv)
        Myutil.settv(jiJianCanJiBean.gangwei_name,h.gangweiTv)
        Myutil.settv(Myutil.getdata(jiJianCanJiBean.ctime),h.ctimeTv)
        return v
    }

    override fun getItem(position: Int): Any = JiJianCaiJiBeans[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getCount(): Int = JiJianCaiJiBeans.size
    class Header(var v : View){
        val mcodeTv=v.mcodeTv
        val mb_batch=v.mb_batchTv
        val nameTv=v.nameTv
        val ctimeTv=v.ctimeTv
        val gangweiTv=v.gangweiTv
    }
}